# connect to the J-Link gdb server
target remote localhost:2331

# Set gdb server to little endian
monitor endian little

# Set JTAG speed to 1000 kHz
monitor speed 1000

# Reset the target
monitor reset
monitor sleep 100

# Set JTAG speed to 2000 khz
monitor speed 2000

#initilized system clock & DRAM
monitor long 0xb0000004 = 0x0003273F
monitor long 0xb0000228 = 0x00001178    #/* MPLL=192MHz=0x1140 */
monitor long 0xb0000224 = 0x00001150    #/* UPLL=162MHz=0x196c */
 
monitor long 0xb0000220 = 0x000009EC
monitor long 0xb0000240 = 0x00000008    #/* DRAM source from MPLL = DRAM_N=0 */
monitor long 0xb000020C = 0x00000018    #/* System clock source from UPLL */
monitor long 0xb0000214 = 0x001F0000
monitor long 0xb000021C = 0x00000900    #/* CPU_N = 0 = HCLK234_N = 0 = APB_N=1 (clock divider ratio)*/
monitor long 0xb0000204 = 0xFFFFFFFF
monitor long 0xb0000208 = 0xFFFFFFFF

monitor long 0xb0003054 = 0x0000001b    #/*DLLMODE */

monitor long 0xb0003034 = 0x00888800
monitor long 0xb0003008 = 0x0000805A
monitor long 0xb0003028 = 0x2AA9394A    #/*** bon= 0x2AFF3B4A ***/

monitor long 0xb0003010 = 0x00000006
monitor long 0xb0003004 = 0x00000021
monitor long 0xb0003004 = 0x00000023
monitor long 0xb0003004 = 0x00000027
monitor long 0xb0003020 = 0x00008000
monitor long 0xb0003024 = 0x00008000
monitor long 0xb000301C = 0x00002402
monitor long 0xb0003018 = 0x00000532
monitor long 0xb0003004 = 0x00000027
monitor long 0xb0003004 = 0x0000002B
monitor long 0xb0003004 = 0x0000002B
monitor long 0xb0003018 = 0x00000432
monitor long 0xb000301C = 0x00002782
monitor long 0xb000301C = 0x00002402
monitor long 0xb0003004 = 0x00000020

monitor long 0xb0003000 = 0x05330476    #/* enable PHASE_RESET & RF_RdDataSel_R=1 for auto-cal. Enable */
monitor long 0xb0003000 = 0x05230476
 
#wait for moment
monitor sleep 20

#load the debug image
load

#set cpu to svc mode(on cpu reset)
monitor reg cpsr = 0xd3

#debug in ram 
monitor reg pc   = 0x00000000

#debug begin
 